namespace Radar
{
    using System;

    internal sealed class GenericFactoryBuilder : FactoryBuilder
    {
        public GenericFactoryBuilder(Type implementationType, IContainer container, IConfigurationProvider configurationProvider)
            : base(implementationType, container, configurationProvider)
        {
        }

        protected override Type FindSuitableType(Type baseType, params Type[] arguments)
        {
            return baseType.MakeGenericType(arguments);
        }

        protected override void ValidateImplementationType(Type type)
        {
            base.ValidateImplementationType(type);

            if (!type.IsGenericTypeDefinition)
                throw Error("Type {0} is not a generic type definition", type);
        }
    }
}